// house_pkg/pages/room/index.ts
Page({

  /**
   * 页面的初始数据
   */
  data: {
    point: '',
    building: '',
    rooms: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad({ point, building }) {
    // console.log(point, building)
    this.fake(point, building)
  },
  fake(point, building) {
    // 随机生成房间个数
    const size = Math.floor(Math.random() * 5) + 4
    const rooms = []
    for (let i = 0; i < size; i++) {
      // 楼号随机生成
      const floor = Math.floor(Math.random() * 19) + 1
      // 具体的房间号生成 1 ~ 3
      const No = Math.floor(Math.random() * 3) + 1
      const room = [floor, 0, No].join('')
      // console.log(room);
      if (rooms.includes(room)) return
      rooms.push(room)
    }
    // 渲染数据
    this.setData({ rooms, point, building })
  }
})